﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using fmtx.Framework.SqlHelper;
using PressureTest.Model;

namespace PressureTest
{
    public partial class InstillForm : Form
    {
        List<UserInfo> users;
        public InstillForm(List<UserInfo> _users)
        {
            users = _users;
            InitializeComponent();
        }

        private void btnok_Click(object sender, EventArgs e)
        {
            btnok.Enabled = false;
            var conn=txtsqlconn.Text;
            try
            {
                using (var read = SqlHelper.ExecuteReader(conn, CommandType.Text, txtsqlselect.Text))
                {
                    if (read.HasRows)
                    {
                        while (read.Read())
                        {
                            users.Add(new UserInfo(read["uname"].ToString()));
                        }
                    }
                }
            }
            catch (Exception)
            {

            }
            btnok.Enabled = true;
            if (users.Count==0)
            {
                MessageBox.Show("无法获取测试数据！");
            }
            else
            {
                this.Close();
            }
        }
    }
}
